import React, { Component, createRef } from "react";

// 因为文件上传框是只读的
// 所以不能做成受控组件

class App extends Component {
  constructor() {
    super();
    this.state = {};
    this.file = createRef();
  }

  fn = () => {
    console.log(this.file.current.files[0]);
  };

  render() {
    return (
      <>
        <h2>文件上传框</h2>
        <input type="file" ref={this.file} multiple />

        <button onClick={this.fn}>提交</button>
      </>
    );
  }
}

export default App;
